from tqsdk import TqApi, TqAuth, TqBacktest,TqSim
from info import  TQ_username,TQ_password
from datetime import date

class TQapi:
    def __init__(self,signalHandle) -> None:
        self.closeGUI=False
        ##登陆账号
        
        try:
            auth=TqAuth(TQ_username,TQ_password)
            #实盘
            self.api = TqApi(auth=auth)
            #回测
            # backtest = TqBacktest(start_dt=date(2024, 9, 1), end_dt=date(2024, 9, 30))
            # self.api = TqApi(TqSim(1000000), backtest=backtest, auth=auth)

        except:
            raise Exception('登陆失败')

    